## NA values found in column: q71 - Number of NAs: 12
## 
## Caricamento pacchetto: 'lubridate'
## I seguenti oggetti sono mascherati da 'package:base':
## 
##     date, intersect, setdiff, union

From the graphs above we can see that, while the DMA score computation looks incorrect, the error stems from just 3 dimensions out of 6: dimension 2,3 and 4, with dimension 2 being the most “biased” one on average.

##  [1]   12   13   16   36   92  123  136  567 1488 2322 2392 2446 3503
##      time                                 sme_name assess_date
## 12      0                          My favorite SME  2023-03-03
## 13      0                          My favorite SME  2023-03-08
## 16      1                          My favorite SME  2023-03-10
## 36      0                            TESTE COMPANY  2023-04-13
## 92      0                              TESTE MPS 2  2023-05-15
## 123     0                                Statotest  2023-05-30
## 136     0              Biedrība "KOKMUIŽA" (tests)  2023-05-31
## 567     0 Sertifikācijas un testēšanas centrs, SIA  2023-08-09
## 1488    0                                  test aa  2023-11-23
## 2322    0                                test ondo  2024-01-18
## 2392    1                                test ondo  2024-01-19
## 2446    0                                 SME test  2024-01-23
## 3503    0                                 Test SME  2024-03-19
##                                      ent_name            fiscal_code q11ai
## 12                            My favorite SME 9.9999999999999904E+23     0
## 13                            My favorite SME 9.9999999999999904E+23     1
## 16                            My favorite SME 9.9999999999999904E+23     0
## 36                              TESTE COMPANY              529897768     1
## 92                                TESTE MPS 2              303311509     0
## 123                                 Statotest             CZ09380949     1
## 136                                SIA Arbora            43603053170     1
## 567  Sertifikācijas un testēšanas centrs, SIA            40003025542     1
## 1488                                  test aa              0900238CY     0
## 2322                                test ondo            BG175036374     0
## 2392                                test ondo            BG175036374     1
## 2446                                 SME test               CZ123456     0
## 3503                                 Test SME  No VAT Num applicable     1
##      q11pi q12ai q12pi q13ai q13pi q14ai q14pi q15ai q15pi q16ai q16pi q17ai
## 12       0     0     0     0     0     0     0     0     0     0     0     0
## 13       0     1     0     1     0     1     0     0     0     0     0     0
## 16       0     0     0     0     0     0     0     0     0     0     0     0
## 36       0     0     1     1     0     0     1     1     0     0     0     1
## 92       0     0     0     0     0     0     0     0     0     0     0     0
## 123      0     1     0     1     0     0     1     0     1     0     1     0
## 136      0     0     1     1     0     0     1     1     0     0     1     1
## 567      0     1     0     1     1     0     1     1     0     0     1     0
## 1488     0     0     0     0     0     0     0     0     0     0     0     0
## 2322     1     0     1     0     1     0     1     0     1     0     0     0
## 2392     1     1     1     0     1     0     0     0     0     0     0     0
## 2446     0     0     0     0     0     0     0     0     0     0     0     0
## 3503     1     1     0     1     0     1     0     0     1     0     0     0
##      q17pi q18ai q18pi q19ai q19pi q110ai q110pi q21 q22 q23 q24 q25 q26 q27
## 12       0     0     0     0     0      0      0   0   0   0   0   0   0   0
## 13       0     0     0     0     0      0      0   0   0   1   0   0   1   0
## 16       0     0     0     0     0      0      0   0   0   0   0   0   0   0
## 36       0     0     1     1     0      0      1   0   1   0   1   0   1   0
## 92       0     0     0     0     0      0      0   0   0   0   0   0   0   0
## 123      1     1     0     0     1      1      0   1   1   1   1   0   0   1
## 136      0     0     1     1     0      0      1   0   0   0   0   0   0   0
## 567      1     1     0     1     0      0      1   1   0   1   1   1   1   1
## 1488     0     0     0     0     0      0      0   0   0   0   0   0   0   0
## 2322     0     0     0     0     0      0      0   0   0   0   0   0   0   0
## 2392     0     0     0     0     0      0      0   1   1   1   1   1   1   1
## 2446     0     0     0     0     0      0      0   0   0   0   0   0   0   0
## 3503     0     0     0     0     0      1      0   1   1   0   0   0   0   0
##      q28 q29 q210 q31 q32 q33 q34 q35 q36 q37 q38 q39 q310 q41 q42 q43 q44 q45
## 12     0   0    0   0   0   0   0   0   0   0   0   0    0 0.0 0.0 0.0 0.0 0.0
## 13     0   0    0   0   0   0   0   0   0   0   0   0    0 0.0 0.0 0.0 0.0 0.0
## 16     0   0    0   0   0   0   0   0   0   0   0   0    0 0.0 0.0 0.0 0.0 0.0
## 36     0   0    0   0   1   0   1   1   1   0   0   0    0 0.2 0.4 0.6 0.6 0.4
## 92     0   0    0   0   0   0   0   0   0   0   0   0    0 0.0 0.0 0.0 0.0 0.0
## 123    1   0    0   1   1   0   0   0   0   0   1   0    1 0.8 0.0 1.0 0.0 1.0
## 136    0   0    0   0   0   0   0   0   0   0   0   0    0 0.6 0.8 0.8 0.6 0.8
## 567    0   1    0   1   1   1   0   0   0   0   1   0    0 0.0 0.0 0.0 0.0 0.0
## 1488   0   0    0   0   0   0   0   0   0   0   0   0    0 0.0 0.0 0.0 0.0 0.0
## 2322   0   0    1   1   0   0   0   0   0   0   0   0    0 0.8 0.6 0.4 0.2 0.0
## 2392   1   1    1   1   1   1   1   1   1   1   1   1    1 1.0 1.0 1.0 1.0 1.0
## 2446   0   0    0   0   0   0   0   0   0   0   0   0    0 0.0 0.0 0.0 0.0 0.0
## 3503   1   1    0   1   1   0   1   0   0   0   1   0    1 1.0 0.4 0.8 0.8 0.8
##      q46 q47 q51 q52 q53 q54 q55 q56 q57 q61 q62 q63 q64 q65 q66 q67 q68 q71
## 12   0.0 0.0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
## 13   0.0 0.0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
## 16   0.0 0.0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
## 36   0.4 0.6   0   1   0   1   0   1   0   0   1   1   1   1   0   0   0   0
## 92   0.0 0.0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
## 123  0.0 0.0   0   0   1   0   0   0   0   0   1   0   0   1   0   0   0   1
## 136  0.8 0.6   0   1   0   1   0   1   0   0   0   0   0   0   0   0   0   0
## 567  0.0 0.0   1   1   1   1   0   1   0   1   1   1   0   1   1   1   0   1
## 1488 0.0 0.0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
## 2322 1.0 0.0   0   0   0   0   0   1   0   0   0   0   0   0   1   0   0   0
## 2392 1.0 1.0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
## 2446 0.0 0.0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
## 3503 0.2 0.4   1   1   0   1   0   1   0   1   1   0   1   0   1   0   0   1
##      q72 q73 q74 q75 q76 q77 q78 q81 q82 q83 q84 q85 q86 q91 q92 q93 q94 q95
## 12     0   0   0   0   0   0   0   0   0   0   0   0   0 0.0 0.0 0.0 0.0 0.0
## 13     0   0   0   0   0   0   0   0   0   0   0   0   0 0.0 0.0 0.0 0.0 0.0
## 16     0   0   0   0   0   0   0   0   0   0   0   0   0 0.0 0.0 0.0 0.0 0.0
## 36     0   1   1   1   0   0   0   0   1   0   1   1   0 0.2 0.4 0.6 0.4 0.6
## 92     0   0   0   0   0   0   0   0   0   0   0   0   0 0.0 0.0 0.0 0.0 0.0
## 123    0   1   1   1   1   0   0   0   1   0   0   1   0 0.0 0.0 0.0 0.0 1.0
## 136    0   1   0   1   0   1   0   0   1   0   1   0   1 0.6 0.8 0.6 0.8 0.6
## 567    0   1   1   1   1   0   0   1   1   1   1   1   1 0.0 0.0 0.0 0.0 0.0
## 1488   0   0   0   0   0   0   0   0   0   0   0   0   0 0.0 0.0 0.0 0.0 0.0
## 2322   0   0   1   0   0   0   0   0   0   0   0   1   0 1.0 0.8 0.6 0.4 0.2
## 2392   1   1   1   1   1   1   1   1   1   1   1   1   1 1.0 1.0 1.0 1.0 1.0
## 2446   0   0   0   0   0   0   0   0   0   0   0   0   0 0.0 0.0 0.0 0.0 0.0
## 3503   0   1   0   0   0   0   0   1   1   1   1   1   1 0.2 0.4 0.6 1.0 0.8
##      q101 q102 q103 q104 q105 q106 q107 q108 q109 q1010 q111 q112 q113 q114
## 12      0    0    0    0    0    0    0    0    0     0    0    0    0    0
## 13      0    0    0    0    0    0    0    0    0     0    0    0    0    0
## 16      0    0    0    0    0    0    0    0    0     0    0    0    0    0
## 36      0    1    1    1    0    0    0    0    0     0    1    2    0    1
## 92      0    0    0    0    0    0    0    0    0     0    0    0    0    0
## 123     0    0    0    0    0    0    0    0    0     1    1    0    1    0
## 136     0    1    1    0    1    0    1    0    1     0    2    1    1    1
## 567     0    0    0    0    0    0    1    1    0     1    1    0    1    0
## 1488    0    0    0    0    0    0    0    0    0     0    0    0    0    0
## 2322    0    0    0    0    0    0    0    0    0     1    1    2    2    1
## 2392    1    1    1    1    1    1    1    1    1     1    2    1    1    1
## 2446    0    0    0    0    0    0    0    0    0     0    0    0    0    0
## 3503    1    1    0    1    1    0    1    0    0     1    1    2    0    0
##      q115 dmascore dbsscore drscore hcdscore dmscore aaiscore gdscore q1score
## 12      0        0        0       0        0       0        0       0       0
## 13      0        3       20       0        0       0        0       0      13
## 16      0        0        0       0        0       0        0       0       0
## 36      0       42       40      43       46      46       44      35      30
## 92      0        0        0       0        0       0        0       0       0
## 123     0       33       53      40       20      52       20      15      33
## 136     1       43       33      36       21      46       68      55      33
## 567     1       45       60      20       73      86        0      30      37
## 1488    0        0        0       0        0       0        0       0       0
## 2322    0       28       20      26       13      15       60      35      17
## 2392    1       88       50     100      100     100      100      80      17
## 2446    0        0        0       0        0       0        0       0       0
## 3503    2       54       37      56       54      64       60      55      23
##      q2score q3score q4score q5score q6score q7score q8score q9score q10score
## 12         0       0       0       0       0       0       0       0        0
## 13         7       0       0       0       0       0       0       0        0
## 16         0       0       0       0       0       0       0       0        0
## 36        10      20      23      21      25      21      25      44       15
## 92         0       0       0       0       0       0       0       0        0
## 123       20      20      20       7      12      36      17      20        5
## 136        0       0      36      21       0      21      25      68       25
## 567       23      20       0      36      38      36      50       0       15
## 1488       0       0       0       0       0       0       0       0        0
## 2322       3       5      21       7       6       7       8      60        5
## 2392      33      50      50      50      50      50      50     100       50
## 2446       0       0       0       0       0       0       0       0        0
## 3503      13      25      31      29      25      14      50      60       30
##      q11score
## 12          0
## 13          0
## 16          0
## 36         20
## 92          0
## 123        10
## 136        30
## 567        15
## 1488        0
## 2322       30
## 2392       30
## 2446        0
## 3503       25
## [1] 2109 2445
##                                      sme_name fiscal_code time assess_date
## 2138 Sertifikācijas un testēšanas centrs, SIA 40003025542    0  2023-08-09
## 2476                                Statotest  CZ09380949    0  2023-05-30
##                                      ent_name q11ai q11pi q12ai q12pi q13ai
## 2138 Sertifikācijas un testēšanas centrs, SIA     1     0     1     0     1
## 2476                                Statotest     1     0     1     0     1
##      q13pi q14ai q14pi q15ai q15pi q16ai q16pi q17ai q17pi q18ai q18pi q19ai
## 2138     1     0     1     1     0     0     1     0     1     1     0     1
## 2476     0     0     1     0     1     0     1     0     1     1     0     0
##      q19pi q110ai q110pi q21 q22 q23 q24 q25 q26 q27 q28 q29 q210 q31 q32 q33
## 2138     0      0      1   1   0   1   1   1   1   1   0   1    0   1   1   1
## 2476     1      1      0   1   1   1   1   0   0   1   1   0    0   1   1   0
##      q34 q35 q36 q37 q38 q39 q310 q41 q42 q43 q44 q45 q46 q47 q51 q52 q53 q54
## 2138   0   0   0   0   1   0    0 0.0   0   0   0   0   0   0   1   1   1   1
## 2476   0   0   0   0   1   0    1 0.8   0   1   0   1   0   0   0   0   1   0
##      q55 q56 q57 q61 q62 q63 q64 q65 q66 q67 q68 q71 q72 q73 q74 q75 q76 q77
## 2138   0   1   0   1   1   1   0   1   1   1   0   1   0   1   1   1   1   0
## 2476   0   0   0   0   1   0   0   1   0   0   0   1   0   1   1   1   1   0
##      q78 q81 q82 q83 q84 q85 q86 q91 q92 q93 q94 q95 q101 q102 q103 q104 q105
## 2138   0   1   1   1   1   1   1   0   0   0   0   0    0    0    0    0    0
## 2476   0   0   1   0   0   1   0   0   0   0   0   1    0    0    0    0    0
##      q106 q107 q108 q109 q1010 q111 q112 q113 q114 q115 dmascore dbsscore
## 2138    0    1    1    0     1    1    0    1    0    1       45       60
## 2476    0    0    0    0     1    1    0    1    0    0       33       53
##      drscore hcdscore dmscore aaiscore gdscore q1score q2score q3score q4score
## 2138      20       73      86        0      30      37      23      20       0
## 2476      40       20      52       20      15      33      20      20      20
##      q5score q6score q7score q8score q9score q10score q11score country
## 2138      36      38      36      50       0       15       15  Latvia
## 2476       7      12      36      17      20        5       10 Czechia
##             region                                            sector
## 2138       Latvija Agricultural biotechnology and food biotechnology
## 2476 Střední Čechy                                          Security
##                    size dma_score dig_business_strat dig_readiness
## 2138 Small-size (10-49)        45                 60            20
## 2476 Small-size (10-49)        33                 53            40
##      hum_centr_dig data_gov automation_ai green_dig   edih_name edih_type
## 2138            73       86             0        30      EDIHLV      EDIH
## 2476            20       52            20        15 EDIH Saxony      EDIH
##      dma_bias dbs_bias dr_bias hcd_bias dm_bias aai_bias gd_bias
## 2138        0        0       0        0       0        0       0
## 2476        0        0       0        0       0        0       0
##   [1] sme_name           fiscal_code        time              
##   [4] assess_date        ent_name           q11ai             
##   [7] q11pi              q12ai              q12pi             
##  [10] q13ai              q13pi              q14ai             
##  [13] q14pi              q15ai              q15pi             
##  [16] q16ai              q16pi              q17ai             
##  [19] q17pi              q18ai              q18pi             
##  [22] q19ai              q19pi              q110ai            
##  [25] q110pi             q21                q22               
##  [28] q23                q24                q25               
##  [31] q26                q27                q28               
##  [34] q29                q210               q31               
##  [37] q32                q33                q34               
##  [40] q35                q36                q37               
##  [43] q38                q39                q310              
##  [46] q41                q42                q43               
##  [49] q44                q45                q46               
##  [52] q47                q51                q52               
##  [55] q53                q54                q55               
##  [58] q56                q57                q61               
##  [61] q62                q63                q64               
##  [64] q65                q66                q67               
##  [67] q68                q71                q72               
##  [70] q73                q74                q75               
##  [73] q76                q77                q78               
##  [76] q81                q82                q83               
##  [79] q84                q85                q86               
##  [82] q91                q92                q93               
##  [85] q94                q95                q101              
##  [88] q102               q103               q104              
##  [91] q105               q106               q107              
##  [94] q108               q109               q1010             
##  [97] q111               q112               q113              
## [100] q114               q115               dmascore          
## [103] dbsscore           drscore            hcdscore          
## [106] dmscore            aaiscore           gdscore           
## [109] q1score            q2score            q3score           
## [112] q4score            q5score            q6score           
## [115] q7score            q8score            q9score           
## [118] q10score           q11score           country           
## [121] region             sector             size              
## [124] dma_score          dig_business_strat dig_readiness     
## [127] hum_centr_dig      data_gov           automation_ai     
## [130] green_dig          edih_name          edih_type         
## [133] dma_bias           dbs_bias           dr_bias           
## [136] hcd_bias           dm_bias            aai_bias          
## [139] gd_bias           
## <0 righe> (o 0-length row.names)
##                           sme_name    fiscal_code     country
## 173               Motas Group B.V.   KVK 66418402 Netherlands
## 223   TOROI DESARROLLOS MARINOS SL      B44872695       Spain
## 243                  Stålhaven ApS       41458682     Denmark
## 247                   wattanywhere  FR34903951317      France
## 487                       Golfmore       33593082     Denmark
## 529           PROSIGMA PLUS D.O.O.       19873662    Slovenia
## 544         Atomic Advertising Ltd     IE8279207C     Ireland
## 795           SIA Ganību dambis 15    40103992961      Latvia
## 908                 Konrad Holding   0656.636.154     Belgium
## 943             mar di levante srl    06353080721       Italy
## 1038     Ruponen Olli-Pekka Sakari      1328645-8     Finland
## 1386 Baltic Transport Partner, UAB         NO VAT   Lithuania
## 1564                     StartBite    IE4078322AH     Ireland
## 1766                Complimac B.V. NL864340011B01 Netherlands
## 1773                      CibusMed      800832330      Greece
## 1812         ELIWELL IBERICA, S.A.      A96127980       Spain
## 1993         SIA "Amber cosmetics"    50103933211      Latvia
## 2098   Inversiones Albarragena SLU      B88160395       Spain
## 2468         Raudonas Mygtukas, MB LT100011030610   Lithuania
## 2546                  Atžalas, UAB      305159582   Lithuania
## 2583                  ELVEZ d.o.o.       76413187    Slovenia
## 3078       Augaliniai gaminiai, MB      305915364   Lithuania
## 3128               Bigger Scope Oy     FI31145114     Finland
## 3148                         GESFI  FR28488817602      France
## 3152         Telco Electronics A/S       87255816     Denmark
##                                   region
## 173                        Noord-Holland
## 223                             Cataluña
## 243                          Nordjylland
## 247                        Franche-Comté
## 487                          Midtjylland
## 529                    Vzhodna Slovenija
## 544                  Eastern and Midland
## 795                              Latvija
## 908                      Prov. Antwerpen
## 943                               Puglia
## 1038                         Etelä-Suomi
## 1386 Vidurio ir vakarų Lietuvos regionas
## 1564                Northern and Western
## 1766                       Noord-Brabant
## 1773                              Attiki
## 1812                Comunitat Valenciana
## 1993                             Latvija
## 2098                         Extremadura
## 2468 Vidurio ir vakarų Lietuvos regionas
## 2546 Vidurio ir vakarų Lietuvos regionas
## 2583                   Zahodna Slovenija
## 3078 Vidurio ir vakarų Lietuvos regionas
## 3128                    Helsinki-Uusimaa
## 3148                            Bretagne
## 3152                         Nordjylland
##                                                 sector                 size
## 173                                  Personal services     Micro-size (1-9)
## 223                       Manufacturing and processing     Micro-size (1-9)
## 243            Metal working and industrial production     Micro-size (1-9)
## 247            Energy, fuels and petroleum engineering     Micro-size (1-9)
## 487                      Cultural and creative economy     Micro-size (1-9)
## 529                                        Environment     Micro-size (1-9)
## 544                      Cultural and creative economy   Small-size (10-49)
## 795                                        Real estate     Micro-size (1-9)
## 908                                         Automotive     Micro-size (1-9)
## 943                               Transport & Mobility     Micro-size (1-9)
## 1038                                Food and beverages     Micro-size (1-9)
## 1386                      Manufacturing and processing   Small-size (10-49)
## 1564                                 Personal services     Micro-size (1-9)
## 1766                           Construction & Assembly   Small-size (10-49)
## 1773                                       Health care   Small-size (10-49)
## 1812                      Manufacturing and processing   Small-size (10-49)
## 1993                                 Consumer products     Micro-size (1-9)
## 2098                                Travel and tourism     Micro-size (1-9)
## 2468                                 Personal services     Micro-size (1-9)
## 2546                      Manufacturing and processing   Small-size (10-49)
## 2583                      Manufacturing and processing Medium-size (50-249)
## 3078 Agricultural biotechnology and food biotechnology     Micro-size (1-9)
## 3128                                Telecommunications     Micro-size (1-9)
## 3148                   Community-Led Local Development   Small-size (10-49)
## 3152                      Manufacturing and processing Medium-size (50-249)
##      time assess_date dma_score dig_business_strat dig_readiness hum_centr_dig
## 173     0  2023-06-21        46                 47            36            54
## 223     0  2024-02-19        41                 40            19            32
## 243     0  2024-02-07        33                 43            36            54
## 247     0  2024-02-16        29                 43            46            13
## 487     0  2024-01-30        50                 63            52            86
## 529     0  2024-01-31        20                 10            35            34
## 544     0  2024-02-08        48                 43            36            86
## 795     0  2024-01-22        14                 47             0            29
## 908     0  2024-02-26        13                 33            25             0
## 943     0  2023-12-28        23                 37            22            21
## 1038    0  2024-01-16        48                 53            38            40
## 1386    0  2023-12-12        16                 37            10            13
## 1564    0  2023-12-04        21                 23            25            20
## 1766    0  2023-11-20        30                 57            26            45
## 1773    0  2023-11-14        59                 60            30            93
## 1812    0  2023-11-21        54                 50            47           100
## 1993    0  2023-10-25        21                 20            20            40
## 2098    0  2023-07-22        38                 40            21            39
## 2468    0  2023-08-29        19                 33            20             7
## 2546    0  2022-11-04         9                 17             8            13
## 2583    0  2023-08-11        50                 47            48            33
## 3078    0  2023-05-29        31                 70            33            46
## 3128    0  2023-05-09        60                 47            50            80
## 3148    0  2023-07-26        36                 50            30            27
## 3152    0  2023-05-03        16                 23            25             6
##      data_gov automation_ai green_dig           edih_name          edih_type
## 173        31            60        50           EDIH-NWNL               EDIH
## 223        31            60        65             DIH4CAT               EDIH
## 243        45            20         0            AddSmart               EDIH
## 247        14            16        40      DEDIHCATED BFC               EDIH
## 487        68             8        20             CD-EDIH               EDIH
## 529        30             0        10             DIGI-SI               EDIH
## 544        52            28        40              CeADAR               EDIH
## 795         7             0         0              EDIHLV               EDIH
## 908         7             0        10           DIGITALIS               EDIH
## 943        15             0        40        CETMA-DIHSME               EDIH
## 1038       30            52        75           Robocoast               EDIH
## 1386       23             0        15   DI4 LITHUANIAN ID               EDIH
## 1564       23            12        20                 FxC               EDIH
## 1766       39             4        10            EDIH-SNL               EDIH
## 1773      100            48        25          HEALTH HUB Seal of Excellence
## 1812       76             0        50              InnDIH               EDIH
## 1993       15             8        25                DAoL               EDIH
## 2098       77             4        45 Tech4EfficiencyEDIH               EDIH
## 2468       24             0        30         EDIH4IAE.LT               EDIH
## 2546       15             0         0         EDIH4IAE.LT               EDIH
## 2583       70            36        65             DIGI-SI               EDIH
## 3078        0             4        35         EDIH4IAE.LT               EDIH
## 3128       93            40        50                FAIR               EDIH
## 3148       63             4        40       EDIH BRETAGNE               EDIH
## 3152       32             0        10            AddSmart               EDIH
##  [1]  290  839 1184 1254 1650 1752 1830 1990 2173 2209 2450 2490 2513 2609 2631
## [16] 2635 2921 3006 3068 3082 3139 3158 3225 3226
##                                       sme_name              fiscal_code
## 290                                   TEST SME                   345678
## 840                                  test ondo              BG175036374
## 1186                            ESMEDRAGO S.L.                B50766021
## 1256                                  Test SME             12/345/67890
## 1652                     Hissmekano Estonia OÜ                 11396053
## 1755                         Al_Test_from form                  1234zxz
## 1833                                      Test              5555-223344
## 1993                     SIA "Amber cosmetics"              50103933211
## 2176      SAINT NAZAIRE AGGLOMERATION TOURISME              828 620 831
## 2212                            Sensmetry, UAB                305079257
## 2453                             Rasmedis, UAB           LT100006759414
## 2493                                Erismet OÜ                 11951193
## 2516                         AL_Test_from site                  1234xzx
## 2612    Ceļu satiksmes drošības direkcija, VAS              40003345734
## 2634 Starptautiskā Kosmetoloģijas koledža, SIA              40003253478
## 2638  Sertifikācijas un testēšanas centrs, SIA              40003025542
## 2924                                      test                   123458
## 3009                                    Presme                125341366
## 3071                                 Statotest               CZ09380949
## 3085               Biedrība "KOKMUIŽA" (tests)              43603053170
## 3142                                      Test                 07777777
## 3161                                   tests 2                 25242333
## 3229                           My favorite SME 999999999999999999999999
## 3230                                      test                  2222222
##        country                              region
## 290    Ireland                            Southern
## 840   Bulgaria                        Yugoiztochen
## 1186     Spain                              Aragón
## 1256   Germany                           Karlsruhe
## 1652   Estonia                               Eesti
## 1755     Italy                             Sicilia
## 1833    Sweden                 Norra Mellansverige
## 1993    Latvia                             Latvija
## 2176    France                    Pays de la Loire
## 2212 Lithuania Vidurio ir vakarų Lietuvos regionas
## 2453 Lithuania Vidurio ir vakarų Lietuvos regionas
## 2493   Estonia                               Eesti
## 2516     Italy                             Sicilia
## 2612    Latvia                             Latvija
## 2634    Latvia                             Latvija
## 2638    Latvia                             Latvija
## 2924     Spain                           Andalucía
## 3009 Lithuania Vidurio ir vakarų Lietuvos regionas
## 3071   Czechia                       Střední Čechy
## 3085    Latvia                                <NA>
## 3142  Bulgaria                      Severoiztochen
## 3161    Latvia                             Latvija
## 3229    France                                <NA>
## 3230    Latvia                                <NA>
##                                                 sector
## 290                                             Energy
## 840  Agricultural biotechnology and food biotechnology
## 1186 Agricultural biotechnology and food biotechnology
## 1256                                        Automotive
## 1652                      Manufacturing and processing
## 1755                                            Energy
## 1833                      Manufacturing and processing
## 1993                                 Consumer products
## 2176                                Travel and tourism
## 2212                                Telecommunications
## 2453                      Manufacturing and processing
## 2493                      Manufacturing and processing
## 2516           Energy, fuels and petroleum engineering
## 2612                             Public administration
## 2634                                       Health care
## 2638 Agricultural biotechnology and food biotechnology
## 2924 Agricultural biotechnology and food biotechnology
## 3009                                 Personal services
## 3071                                          Security
## 3085                                 Consumer products
## 3142 Agricultural biotechnology and food biotechnology
## 3161                                       Aeronautics
## 3229                                        Automotive
## 3230                                        Automotive
##                                   size time assess_date dma_score
## 290                 Small-size (10-49)    0  2024-02-13        43
## 840                   Micro-size (1-9)    1  2024-01-19        88
## 1186                Small-size (10-49)    0  2023-11-20        36
## 1256              Medium-size (50-249)    0  2023-12-18        38
## 1652                Small-size (10-49)    0  2023-10-30        40
## 1755                  Micro-size (1-9)    0  2023-08-22        52
## 1833                Small-size (10-49)    2  2024-01-25        36
## 1993                  Micro-size (1-9)    0  2023-10-25        21
## 2176                Small-size (10-49)    0  2023-09-25        30
## 2212                Small-size (10-49)    0  2023-07-13        16
## 2453                  Micro-size (1-9)    0  2023-08-16         8
## 2493                  Micro-size (1-9)    1  2023-12-27        47
## 2516                  Micro-size (1-9)    0  2023-08-22        55
## 2612 Small mid-cap (250-499 employees)    0  2023-08-10        86
## 2634                Small-size (10-49)    0  2023-08-09        48
## 2638                Small-size (10-49)    0  2023-08-09        45
## 2924                Small-size (10-49)    0  2023-06-19        37
## 3009                  Micro-size (1-9)    0  2023-06-12        29
## 3071                Small-size (10-49)    0  2023-05-30        33
## 3085              Medium-size (50-249)    0  2023-05-31        43
## 3142 Small mid-cap (250-499 employees)    0  2023-05-04        23
## 3161                  Micro-size (1-9)    0  2023-05-11        45
## 3229                Small-size (10-49)    0  2023-03-08         3
## 3230                Small-size (10-49)    0  2023-02-21        23
##      dig_business_strat dig_readiness hum_centr_dig data_gov automation_ai
## 290                  47            34            40       62            20
## 840                  50           100           100      100           100
## 1186                 33            25            59       30            24
## 1256                 40            32            33       31            36
## 1652                 57            41            46       29            40
## 1755                 53            56            81       44            40
## 1833                 37            42            27       30            32
## 1993                 20            20            40       15             8
## 2176                 43            35            32       38             4
## 2212                 10            41             6       24            16
## 2453                 23            20             0        0             0
## 2493                 50            71            34       51            36
## 2516                 53            56            81       44            40
## 2612                100            66            93      100            72
## 2634                 63            33            80       48            12
## 2638                 60            20            73       86             0
## 2924                 33            39            27       31            48
## 3009                 23            21            33       38            16
## 3071                 53            40            20       52            20
## 3085                 33            36            21       46            68
## 3142                 10            20            27       31            28
## 3161                 57            41            46       46            40
## 3229                 20             0             0        0             0
## 3230                 30            29            13        8            40
##      green_dig      edih_name          edih_type
## 290         55         ENTIRE Seal of Excellence
## 840         80   AgroDigiRise               EDIH
## 1186        45    Aragon EDIH               EDIH
## 1256        55      EDIH-AICS               EDIH
## 1652        25           AIRE               EDIH
## 1755        40      ARTES 5.0               EDIH
## 1833        45    MIGHTY EDIH Seal of Excellence
## 1993        25           DAoL               EDIH
## 2176        30           DIVA               EDIH
## 2212         0    EDIH4IAE.LT               EDIH
## 2453         5    EDIH4IAE.LT               EDIH
## 2493        40           AIRE               EDIH
## 2516        55      ARTES 5.0               EDIH
## 2612        85         EDIHLV               EDIH
## 2634        50         EDIHLV               EDIH
## 2638        30         EDIHLV               EDIH
## 2924        45    AgrotechDIH               EDIH
## 3009        40    EDIH4IAE.LT               EDIH
## 3071        15    EDIH Saxony               EDIH
## 3085        55         EDIHLV               EDIH
## 3142        20 CYBER4All STAR               EDIH
## 3161        40         EDIHLV               EDIH
## 3229         0 DEDIHCATED BFC               EDIH
## 3230        20         EDIHLV               EDIH
##  [1] sme_name           fiscal_code        country            region            
##  [5] sector             size               time               assess_date       
##  [9] dma_score          dig_business_strat dig_readiness      hum_centr_dig     
## [13] data_gov           automation_ai      green_dig          edih_name         
## [17] edih_type         
## <0 righe> (o 0-length row.names)
##                                                                                                 sme_name
## 86                                                                                                 CEATA
## 205                                                                                     Evers & Evers BV
## 220                                                                                  QMware Austria GmbH
## 875                                                                               Método Free 2030, S.L.
## 1135                                                                      Lesecafé und Buchhandlung GmbH
## 1204                                                                                              Creoby
## 1205                                                                                               Treed
## 1494                                                                                          Coronam BV
## 1495                                                                                KMWE Toolmanagers BV
## 1496                                                                                           Keytec BV
## 1497                                                                                            Itter BV
## 1499                                                                                          Boers & Co
## 1501                                                                                     dexter group BV
## 1502                                                                                  van Dijk Inpijn BV
## 1503                                                                              ter Hoek vonkerosie BV
## 1526                                                                                   de Cromvoirtse BV
## 1527                                                                                        Hieselaar BV
## 1529                                                                                     247lasersnijden
## 1530                                                                            Dumaco S'Gravenpolder BV
## 1531                                                                                       TMI Rhenen BV
## 1532                                                                               Arendsen plaatwerk BV
## 1533                                                                        Koolmees Forceer techniek BV
## 1534                                                                                          Metagro BV
## 1535                                                                                         Suplacon BV
## 1536                                                                                        BOZ group BV
## 1695                                                                                        riprova2FORM
## 2005                                                                                    Cocina Alve S.l.
## 2027                                                                        Perfici Intelligence Limited
## 2029                                                                                     Searsol Limited
## 2183                                                                                Palko Interactive Oy
## 2184                                                                                      ayeaye systems
## 2226                                                                   STW - Sächsische Textilwerke GmbH
## 2515                                                                                                AuRo
## 2594                                                                                        Gasokol GmbH
## 2603                                                                                              B-Side
## 2890 thinkport VIENNA - logistics innovations hub. Verein zur Förderung von Innovationen in der Logistik
## 2905                                                                                                   d
## 3072                                                                                              Glaice
## 3145                                                                         ArtRock Kletterwände GesmbH
## 3211                                                                                                pair
## 3214                                                                                            honeepot
##                                                                                                                                                                                                                                                                         fiscal_code
## 86   B06943161\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t PERIODO \tMES 1\t\t\t\tMES 2\t\t\t\tMES 3\t\t\t\tMES 4\t\t\t\tMES 5\t FASE 1: PRESENTACIÓN Y LANZAMIENTO\tS1\tS2\tS3\tS4\tS5\tS6\tS7\tS8\tS9\tS10\tS11\tS12\tS13\tS14\tS15\tS16\tS17\tS18 Revisión de la planificación y lanzamiento
## 205                                                                                                                                                                                                                                                                  NL813566630b01
## 220                                                                                                                                                                                                                                                                      FN 579018y
## 875                                                                                                                                                                                                                                                          Método Free 2030, S.L.
## 1135                                                                                                                                                                                                                                                          USt-IdNr.DE 111619655
## 1204                                                                                                                                                                                                                                                               Not funded, yet.
## 1205                                                                                                                                                                                                                                                              Not founded, yet.
## 1494                                                                                                                                                                                                                                                                 nl006629982b01
## 1495                                                                                                                                                                                                                                                                 nl810727699b01
## 1496                                                                                                                                                                                                                                                                 nl809191581b01
## 1497                                                                                                                                                                                                                                                                 nl004635644b01
## 1499                                                                                                                                                                                                                                                                 nl005671796b01
## 1501                                                                                                                                                                                                                                                                 nl826128300b01
## 1502                                                                                                                                                                                                                                                                 nl800138417b01
## 1503                                                                                                                                                                                                                                                                 nl814215919b01
## 1526                                                                                                                                                                                                                                                                 nl009908948b01
## 1527                                                                                                                                                                                                                                                                 nl820459422b01
## 1529                                                                                                                                                                                                                                                                 nl859100303b01
## 1530                                                                                                                                                                                                                                                                 nl812375932b01
## 1531                                                                                                                                                                                                                                                                 nl007624451b01
## 1532                                                                                                                                                                                                                                                                 nl802718280b01
## 1533                                                                                                                                                                                                                                                                 nl803844694b01
## 1534                                                                                                                                                                                                                                                                nl8056625872b01
## 1535                                                                                                                                                                                                                                                                 nl009930759b01
## 1536                                                                                                                                                                                                                                                                 nl003720718b01
## 1695                                                                                                                                                                                                                                                                       1234abcd
## 2005                                                                                                                                                                                                                                                                      b78591740
## 2027                                                                                                                                                                                                                                                                    IE3771595sh
## 2029                                                                                                                                                                                                                                                                     03494625hh
## 2183                                                                                                                                                                                                                                                             Y-tunnus 2232282-8
## 2184                                                                                                                                                                                                                                                                NL86a4814380B01
## 2226                                                                                                                                                                                                                                                                 unbekannt (39)
## 2515                                                                                                                                                                                                                                              not yet available August 22, 2023
## 2594                                                                                                                                                                                                                                                                      FN138911g
## 2603                                                                                                                                                                                                                                                                   be0470199481
## 2890                                                                                                                                                                                                                                                           ZVR-Zahl: 1816907511
## 2905                                                                                                                                                                                                                                                                              d
## 3072                                                                                                                                                                                                                                                                     ausstehend
## 3145                                                                                                                                                                                                                                                FN 33519 v, LG Innsbruck, Tirol
## 3211                                                                                                                                                                                                                                                            not yet available 2
## 3214                                                                                                                                                                                                                                                              not yet available
##          country                     region
## 86         Spain Comunidad Foral de Navarra
## 205  Netherlands              Noord-Brabant
## 220      Austria                       Wien
## 875        Spain        Comunidad de Madrid
## 1135     Germany                  Darmstadt
## 1204     Germany                       Köln
## 1205     Germany                       Köln
## 1494 Netherlands              Noord-Holland
## 1495 Netherlands              Noord-Brabant
## 1496 Netherlands               Limburg (NL)
## 1497 Netherlands                 Overijssel
## 1499 Netherlands               Zuid-Holland
## 1501 Netherlands                 Gelderland
## 1502 Netherlands               Zuid-Holland
## 1503 Netherlands                 Overijssel
## 1526 Netherlands              Noord-Brabant
## 1527 Netherlands               Zuid-Holland
## 1529 Netherlands               Zuid-Holland
## 1530 Netherlands                    Zeeland
## 1531 Netherlands                    Utrecht
## 1532 Netherlands                 Gelderland
## 1533 Netherlands               Zuid-Holland
## 1534 Netherlands                 Gelderland
## 1535 Netherlands                  Flevoland
## 1536 Netherlands              Noord-Brabant
## 1695       Italy                    Sicilia
## 2005       Spain        Comunidad de Madrid
## 2027     Ireland       Northern and Western
## 2029     Ireland       Northern and Western
## 2183     Finland                Etelä-Suomi
## 2184 Netherlands              Noord-Holland
## 2226     Germany                   Chemnitz
## 2515     Germany                    Hamburg
## 2594     Austria             Oberösterreich
## 2603     Belgium              Prov. Hainaut
## 2890     Austria                       Wien
## 2905       Spain                 País Vasco
## 3072     Germany                    Leipzig
## 3145     Austria                      Tirol
## 3211     Germany                    Hamburg
## 3214     Germany                    Hamburg
##                                       sector                 size time
## 86                               Environment     Micro-size (1-9)    0
## 205             Manufacturing and processing   Small-size (10-49)    0
## 220                                Education   Small-size (10-49)    0
## 875                                Education     Micro-size (1-9)    0
## 1135           Cultural and creative economy     Micro-size (1-9)    0
## 1204                                  Energy     Micro-size (1-9)    0
## 1205         Community-Led Local Development     Micro-size (1-9)    0
## 1494 Metal working and industrial production Medium-size (50-249)    0
## 1495 Metal working and industrial production   Small-size (10-49)    0
## 1496 Metal working and industrial production Medium-size (50-249)    0
## 1497 Metal working and industrial production   Small-size (10-49)    0
## 1499            Manufacturing and processing Medium-size (50-249)    0
## 1501            Manufacturing and processing Medium-size (50-249)    0
## 1502            Manufacturing and processing Medium-size (50-249)    0
## 1503 Metal working and industrial production Medium-size (50-249)    0
## 1526            Manufacturing and processing Medium-size (50-249)    0
## 1527 Metal working and industrial production Medium-size (50-249)    0
## 1529 Metal working and industrial production   Small-size (10-49)    0
## 1530 Metal working and industrial production Medium-size (50-249)    0
## 1531 Metal working and industrial production   Small-size (10-49)    0
## 1532 Metal working and industrial production   Small-size (10-49)    0
## 1533 Metal working and industrial production   Small-size (10-49)    0
## 1534            Manufacturing and processing Medium-size (50-249)    0
## 1535 Metal working and industrial production Medium-size (50-249)    0
## 1536 Metal working and industrial production Medium-size (50-249)    0
## 1695       Retail, wholesale or distribution   Small-size (10-49)    0
## 2005       Retail, wholesale or distribution   Small-size (10-49)    0
## 2027                           Life sciences     Micro-size (1-9)    0
## 2029                               Education     Micro-size (1-9)    0
## 2183                      Telecommunications     Micro-size (1-9)    0
## 2184                                Maritime     Micro-size (1-9)    0
## 2226                       Consumer products     Micro-size (1-9)    0
## 2515                             Health care     Micro-size (1-9)    0
## 2594            Manufacturing and processing   Small-size (10-49)    0
## 2603            Manufacturing and processing     Micro-size (1-9)    0
## 2890                       Personal services     Micro-size (1-9)    0
## 2905                              Automotive   Small-size (10-49)    0
## 3072                             Health care     Micro-size (1-9)    0
## 3145                       Consumer products   Small-size (10-49)    0
## 3211                       Consumer products     Micro-size (1-9)    0
## 3214                      Travel and tourism     Micro-size (1-9)    0
##      assess_date dma_score dig_business_strat dig_readiness hum_centr_dig
## 86    2024-02-27        46                 67            56            46
## 205   2024-02-20        58                 53            61            86
## 220   2024-02-20        48                 33            39            72
## 875   2024-01-03        15                 17            25             6
## 1135  2023-10-05        16                 30            20            38
## 1204  2023-12-07        35                 40            21            39
## 1205  2023-12-13        19                 27            25            13
## 1494  2023-12-07        45                 40            39            61
## 1495  2023-12-07        51                 50            49            74
## 1496  2023-12-07        40                 33            45            34
## 1497  2023-12-07        43                 37            41            61
## 1499  2023-12-07        57                 57            46            81
## 1501  2023-12-07        30                 37            22            48
## 1502  2023-12-07        58                 53            51            81
## 1503  2023-12-07        43                 40            35            62
## 1526  2023-12-06        59                 60            61            80
## 1527  2023-12-06        45                 40            35            61
## 1529  2023-12-06        65                 57            68            81
## 1530  2023-12-06        54                 53            54            74
## 1531  2023-12-06        32                 40            34            48
## 1532  2023-12-06        45                 43            44            47
## 1533  2023-12-06        42                 47            29            54
## 1534  2023-12-06        51                 60            50            69
## 1535  2023-12-06        62                 57            61            88
## 1536  2023-12-06        64                 53            61            87
## 1695  2023-11-23        50                 50            41            73
## 2005  2023-10-24        34                 47            32            21
## 2027  2023-10-19        49                 47            44            67
## 2029  2023-10-19        39                 40            45            60
## 2183  2023-09-26        53                 53            53            71
## 2184  2023-09-21        39                 20            41            40
## 2226  2023-01-12        44                 40            46            46
## 2515  2023-08-18        15                 13            26             0
## 2594  2023-08-29        41                 53            36            53
## 2603  2023-08-11        70                 50            58            79
## 2890  2023-06-27        35                 30            26            33
## 2905  2023-06-23         7                 10             9             6
## 3072  2023-05-30        39                 50            20            51
## 3145  2023-05-11        52                 50            60            57
## 3211  2023-03-29        39                 57            27            51
## 3214  2023-03-22        46                 60            50            71
##      data_gov automation_ai green_dig          edih_name edih_type
## 86         31             8        65               IRIS      EDIH
## 205        70            16        60           EDIH-SNL      EDIH
## 220        63            48        30        Applied CPS      EDIH
## 875        31             0        10 EDIH MADRID REGION      EDIH
## 1135        8             0         0              EDITH      EDIH
## 1204       61             8        40     EDIH Rheinland      EDIH
## 1205       23             0        25     EDIH Rheinland      EDIH
## 1494       54            24        50           EDIH-SNL      EDIH
## 1495       61            24        45           EDIH-SNL      EDIH
## 1496       61            28        40           EDIH-SNL      EDIH
## 1497       54            12        55           EDIH-SNL      EDIH
## 1499       76            28        55           EDIH-SNL      EDIH
## 1501       32             8        30           EDIH-SNL      EDIH
## 1502       70            40        55           EDIH-SNL      EDIH
## 1503       62            16        45           EDIH-SNL      EDIH
## 1526       69            28        55           EDIH-SNL      EDIH
## 1527       61            24        50           EDIH-SNL      EDIH
## 1529       85            28        70           EDIH-SNL      EDIH
## 1530       69            24        50           EDIH-SNL      EDIH
## 1531       38             4        30           EDIH-SNL      EDIH
## 1532       62            24        50           EDIH-SNL      EDIH
## 1533       54            20        45           EDIH-SNL      EDIH
## 1534       54            20        50           EDIH-SNL      EDIH
## 1535       69            36        60           EDIH-SNL      EDIH
## 1536       77            48        60           EDIH-SNL      EDIH
## 1695       49            40        45          ARTES 5.0      EDIH
## 2005       61             0        45 EDIH MADRID REGION      EDIH
## 2027       70            44        20                FxC      EDIH
## 2029       45             0        45                FxC      EDIH
## 2183       39            56        45          Robocoast      EDIH
## 2184       45            48        40          EDIH-NWNL      EDIH
## 2226       46            24        60        EDIH Saxony      EDIH
## 2515       14            28        10     EDIH4UrbanSAVE      EDIH
## 2594       48             4        50      AI5production      EDIH
## 2603       93            64        75             WalHub      EDIH
## 2890       52            20        50    Crowd in Motion      EDIH
## 2905       15             0         0            CIDIHUB      EDIH
## 3072      100             4        10        EDIH Saxony      EDIH
## 3145       68            32        45    Crowd in Motion      EDIH
## 3211       38            28        35     EDIH4UrbanSAVE      EDIH
## 3214       61            12        20     EDIH4UrbanSAVE      EDIH
## Number of NA values in range q11ai to q115 before replacement: 0
## Number of NA values in range q11ai to q115 after replacement: 0
## Number of NA values in range q11ai to q115 before replacement: 20
## Number of NA values in range q11ai to q115 after replacement: 0

## [1] "Absolute skewness: 0.067091577465314" 
## [2] "Absolute skewness: 0.102116270802807" 
## [3] "Absolute skewness: 0.307264955584877" 
## [4] "Absolute skewness: 0.0207965994059934"
## [5] "Absolute skewness: 0.105006253209107" 
## [6] "Absolute skewness: 1.2166240524527"   
## [7] "Absolute skewness: 0.430328074803944"
## [1] "Absolute kurtosis: 2.41119264783276" "Absolute kurtosis: 2.83421465338019"
## [3] "Absolute kurtosis: 2.67877419769824" "Absolute kurtosis: 1.93188109798596"
## [5] "Absolute kurtosis: 1.94280282161462" "Absolute kurtosis: 4.15331435473708"
## [7] "Absolute kurtosis: 2.51156851122033"

## Reading layer `NUTS_RG_20M_2021_3035' from data source 
##   `C:\Users\feder\OneDrive\Documenti-Fede\Scuola\Università\MSc in Economics\TESI\Master Thesis\Master-Thesis\Data\NUTS_RG_20M_2021_3035.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 2010 features and 9 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -2823672 ymin: -3076354 xmax: 10026280 ymax: 6404813
## Projected CRS: ETRS89-extended / LAEA Europe
## Reading layer `NUTS_RG_20M_2021_3035' from data source 
##   `C:\Users\feder\OneDrive\Documenti-Fede\Scuola\Università\MSc in Economics\TESI\Master Thesis\Master-Thesis\Data\NUTS_RG_20M_2021_3035.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 2010 features and 9 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -2823672 ymin: -3076354 xmax: 10026280 ymax: 6404813
## Projected CRS: ETRS89-extended / LAEA Europe

## [1] 28.34513
## [1] 9

## Reading layer `NUTS_RG_20M_2021_3035' from data source 
##   `C:\Users\feder\OneDrive\Documenti-Fede\Scuola\Università\MSc in Economics\TESI\Master Thesis\Master-Thesis\Data\NUTS_RG_20M_2021_3035.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 2010 features and 9 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -2823672 ymin: -3076354 xmax: 10026280 ymax: 6404813
## Projected CRS: ETRS89-extended / LAEA Europe

library(circlize)
## ========================================
## circlize version 0.4.16
## CRAN page: https://cran.r-project.org/package=circlize
## Github page: https://github.com/jokergoo/circlize
## Documentation: https://jokergoo.github.io/circlize_book/book/
## 
## If you use it in published research, please cite:
## Gu, Z. circlize implements and enhances circular visualization
##   in R. Bioinformatics 2014.
## 
## This message can be suppressed by:
##   suppressPackageStartupMessages(library(circlize))
## ========================================
library(grDevices)

# Define a fixed color palette
fixed_colors <- c(
  dbsscore = "#242424",  #
  drscore = "#3b6a71",   # Corresponds to the third color in node_colors
  hcdscore = "#004494",  # Corresponds to the fourth color in node_colors
  dmscore = "#ed8d2f",   # Corresponds to the fifth color in node_colors
  aaiscore = "#800000",
  gdscore = "#006401"
)

fixed_colors_sub <- c(
  q1score = "#242424",
  q2score = "#242424",
  q3score = "#3b6a71",
  q4score = "#3b6a71",
  q5score = "#004494",
  q6score = "#004494",
  q7score = "#ed8d2f",
  q8score = "#ed8d2f",
  q9score = "#800000",
  q10score = "#006401",
  q11score = "#006401"
)



# Ensure the correlation matrices are prepared correctly
verysmallcorrmatrix[upper.tri(verysmallcorrmatrix)] <- 0
thebigcorrmatrix[upper.tri(thebigcorrmatrix)] <- 0
thebigcorrmatrix <- thebigcorrmatrix[-1, -1]
thebigpolycorrmatrix <- thebigpolycorrmatrix[-1, -1]
thesmallcorrmatrix[upper.tri(thesmallcorrmatrix)] <- 0

# Function to blend two colors with transparency
blend_colors <- function(color1, color2, alpha = 0.7) {
  col1 <- col2rgb(color1, alpha = TRUE)
  col2 <- col2rgb(color2, alpha = TRUE)
  blended <- (col1 * alpha + col2 * (1 - alpha)) / 255
  rgb(blended[1], blended[2], blended[3], alpha = 0.7)  # Set alpha to 0.7 for transparency
}

# Create a color matrix for thesmallcorrmatrix
col_mat <- matrix(NA, nrow = nrow(thesmallcorrmatrix), ncol = ncol(thesmallcorrmatrix))
for (i in 1:nrow(thesmallcorrmatrix)) {
  for (j in 1:ncol(thesmallcorrmatrix)) {
    if (thesmallcorrmatrix[i, j] >= 0.45 && thesmallcorrmatrix[i, j] < 1) {
      col_mat[i, j] <- blend_colors(fixed_colors_sub[names(fixed_colors_sub)[i]], fixed_colors_sub[names(fixed_colors_sub)[j]], alpha = 0.7)
    } else {
      col_mat[i, j] <- "#00000000"
    }
  }
}


# Save the second plot using a graphical device for the chord diagram
png(file.path(paste0(outputfolder, "/thesmallcorrmatrix_plot.png")), width = 2000, height = 2000, res = 300)
chordDiagram(thesmallcorrmatrix, grid.col = fixed_colors_sub, col = col_mat, link.lwd = 2)
dev.off()
## svg 
##   2
# Plot the chord diagram for thesmallcorrmatrix with blended colors




 # Replace with your actual output folder path
#ggsave(filename = file.path(paste0(outputfolder, "/thesmallcorrmatrix_plot.png")))

# Generate colors for verysmallcorrmatrix
num_colors <- length(verysmallcorrmatrix)
colors <- rainbow(num_colors, alpha = 0.7)

# Create a color matrix for verysmallcorrmatrix
col_mat <- matrix(NA, nrow = nrow(verysmallcorrmatrix), ncol = ncol(verysmallcorrmatrix))
for (i in 1:nrow(verysmallcorrmatrix)) {
  for (j in 1:ncol(verysmallcorrmatrix)) {
    if (verysmallcorrmatrix[i, j] >= 0.45 && verysmallcorrmatrix[i, j] < 1) {
      col_mat[i, j] <- blend_colors(fixed_colors[names(fixed_colors)[i]], fixed_colors[names(fixed_colors)[j]], alpha = 0.7)
    } else {
      col_mat[i, j] <- "#00000000"
    }
  }
}

# Plot the chord diagram for verysmallcorrmatrix with blended colors
#chordDiagram(verysmallcorrmatrix, grid.col = fixed_colors, col = col_mat, link.lwd = 2)

# Save the second plot
#ggsave(filename = file.path(paste0(outputfolder, "/thesmallcorrmatrix_plot.png")))

# Save the second plot using a graphical device for the chord diagram
png(file.path(paste0(outputfolder, "/theverysmallcorrmatrix_plot.png")), width = 2000, height = 2000, res = 300)
chordDiagram(verysmallcorrmatrix, grid.col = fixed_colors, col = col_mat, link.lwd = 2)
dev.off()
## svg 
##   2
# Install and load the igraph package if you haven't already done so
if (!require(igraph)) install.packages("igraph")
## Caricamento del pacchetto richiesto: igraph
## 
## Caricamento pacchetto: 'igraph'
## Il seguente oggetto è mascherato da 'package:circlize':
## 
##     degree
## I seguenti oggetti sono mascherati da 'package:dplyr':
## 
##     as_data_frame, groups, union
## I seguenti oggetti sono mascherati da 'package:lubridate':
## 
##     %--%, union
## I seguenti oggetti sono mascherati da 'package:stats':
## 
##     decompose, spectrum
## Il seguente oggetto è mascherato da 'package:base':
## 
##     union
library(igraph)



# Convert the correlation matrix into an adjacency matrix
# By default, the graph will be undirected
graph <- graph_from_adjacency_matrix(thebigcorrmatrix, mode = "undirected", weighted = TRUE, diag = FALSE)
## Warning: The `adjmatrix` argument of `graph_from_adjacency_matrix()` must be symmetric
## with mode = "undirected" as of igraph 1.6.0.
## ℹ Use mode = "max" to achieve the original behavior.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Set edge width based on the weights (correlation strengths)
E(graph)$width <- E(graph)$weight * 2  # Scale the widths as needed

# Choose a layout algorithm, e.g., 'layout_with_fr' for Fruchterman-Reingold
layout <- layout_with_fr(graph)

# Plot the graph
plot(graph, layout = layout, edge.width = E(graph)$width,
     vertex.color = "lightblue", vertex.size = 30,
     vertex.frame.color = "gray", vertex.label.color = "black",
     vertex.label.cex = 0.8, edge.color = "grey50",
     main = "Network Graph of thebigcorrmatrix")

library(igraph)
library(ggplot2)
library(ggraph)



# Convert the correlation matrix into an adjacency matrix
graph <- graph_from_adjacency_matrix(thebigcorrmatrix, mode = "undirected", weighted = TRUE, diag = FALSE)

# Define the threshold
threshold <- 0.3

# Filter edges based on the threshold
graph <- delete_edges(graph, E(graph)[weight <= threshold & weight >= -0.1])




# Set node colors (this could also come from external data)
# node_colors <- c("#242424","#3b6a71", "#004494", "#ed8d2f", "#800000", "#006401")
node_colors <- c(
  "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424",
  "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424",
  "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424", "#242424",
  "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71",
  "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71", "#3b6a71",
  "#004494", "#004494", "#004494", "#004494", "#004494", "#004494", "#004494",
  "#004494", "#004494", "#004494", "#004494", "#004494", "#004494", "#004494", "#004494",
  "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f",
  "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f", "#ed8d2f",
  "#800000", "#800000", "#800000", "#800000", "#800000",
  "#006401", "#006401", "#006401", "#006401", "#006401", "#006401", "#006401", "#006401", "#006401", "#006401",
  "#006401", "#006401", "#006401", "#006401", "#006401"
)

V(graph)$color <- node_colors


# Create a ggraph object using the Fruchterman-Reingold layout
ggraph(graph, layout = 'fr') +
  geom_edge_link(aes(edge_width = weight), color = 'grey50') +
  geom_node_point(size = 5, aes(color = color)) +
  geom_node_text(aes(label = name), vjust = 1.8, color = 'black') +
  theme_void() +
  scale_color_identity() + 
  ggtitle("Network Graph (only correlations above 0.3)") +
  scale_edge_width(range = c(0.1, 1.5))

# Convert the correlation matrix into an adjacency matrix
graph <- graph_from_adjacency_matrix(thebigpolycorrmatrix, mode = "undirected", weighted = TRUE, diag = FALSE)

# Define the threshold
threshold <- 0.3

# Filter edges based on the threshold
graph <- delete_edges(graph, E(graph)[weight <= threshold])



V(graph)$color <- node_colors


# Create a ggraph object using the Fruchterman-Reingold layout
ggraph(graph, layout = 'fr') +
  geom_edge_link(aes(edge_width = weight), color = 'grey50') +
  geom_node_point(size = 5, aes(color = color)) +
  geom_node_text(aes(label = name), vjust = 1.8, color = 'black') +
  theme_void() +
  scale_color_identity() + 
  ggtitle("Network Graph (only correlations above 0.3)") +
  scale_edge_width(range = c(0.1, 3))

ggsave(paste0(outputfolder,"/network_graph.pdf"), width = 10, height = 6) # Save the plot as a PDF file
#pcadata <- datamerge[,c(103,7:102)]
#pcadata <- datamerge[,c(103:109)]
pcadata <- datamerge[,c(103,110:120)]

# Remove rows with any NA values
pcadata <- na.omit(pcadata)






# Load necessary library
if (!require(stats)) install.packages("stats")
library(stats)


# Perform PCA using prcomp
pca_result <- prcomp(pcadata, scale. = TRUE) # Standardize variables

# Proportion of variance explained by each principal component
prop_var_explained <- pca_result$sdev^2 / sum(pca_result$sdev^2)

# Cumulative proportion of variance explained
cum_var_explained <- cumsum(prop_var_explained)

# Determine the number of components to retain
# For example, retain enough components to explain 90% of the variance
num_components_to_retain <- which(cum_var_explained >= 0.90)[1]

# Extract the scores (coordinates) for the retained components
scores <- pca_result$x[, 1:num_components_to_retain]

# Now 'scores' contains the reduced dataset with fewer dimensions

# Visualization

# Scree plot to visualize the variance explained by each principal component
plot(prop_var_explained, xlab = "Principal Component", ylab = "Proportion of Variance Explained", type = "b", pch = 19, main = "Scree Plot")
abline(h = 1 / ncol(pcadata), col = "red", lty = 2) # Adds a reference line for average eigenvalue

# Cumulative variance explained plot
plot(cum_var_explained, xlab = "Number of Principal Components", ylab = "Cumulative Proportion of Variance Explained", type = "b", pch = 19, main = "Cumulative Variance Explained")
abline(h = 0.90, col = "blue", lty = 2) # Adds a reference line at 90% variance explained

# Biplots can show both scores and loadings for the first two principal components
biplot(pca_result, xlabs=rep("", nrow(pcadata)), main = "PCA Biplot", pch = 20, cex = 1)

# The number of components to retain based on the chosen threshold (e.g., 90% cumulative variance explained)
cat("Number of components to retain (90% variance explained):", num_components_to_retain, "\n")
## Number of components to retain (90% variance explained): 8
# Install and load the stargazer package if not already installed
if (!require(stargazer)) install.packages("stargazer")
## Caricamento del pacchetto richiesto: stargazer
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
library(stargazer)


# Extract the loadings (rotation) for the first few principal components
# For example, extracting the first two principal components
loadings <- pca_result$rotation[, 1:5]

# Convert the loadings to a data frame
loadings_df <- as.data.frame(loadings)

# Name the components (optional)
names(loadings_df) <- c("PC1", "PC2")

# Use stargazer to create a table
stargazer(loadings_df, type = "text", title = "Loadings of the First Two Principal Components")
## 
## Loadings of the First Two Principal Components
## ==========================================
## Statistic N   Mean  St. Dev.  Min    Max  
## ------------------------------------------
## PC1       12 -0.285  0.051   -0.396 -0.213
## PC2       12 0.027   0.300   -0.347 0.554 
## NA        12 -0.001  0.302   -0.568 0.537 
## NA.1      12 0.021   0.301   -0.293 0.813 
## NA.2      12 0.004   0.301   -0.569 0.446 
## ------------------------------------------
# library(COINr)
# 
# iData <- data[,c(1,5,6:119)]
# names(iData)[1] <- "Time"
# names(iData)[2] <- "uCode"
# 
# iData <- iData %>% distinct(uCode, Time, .keep_all = TRUE)
# iMeta <- read_xlsx("iMeta.xlsx")
# 
# iData <- iData[iData$Time==0,]
# 
# 
# coin <- new_coin(iData, iMeta)
# 
# pca <- get_PCA(coin, Level = 1, out2 = "list")

# 
# 
# library(grid)
# 
# # Assuming pca_scores_q9 contains the PCA scores for the first two principal components
# # Extract the variable loadings for the first two principal components
# loadings <- pca$PCAresults$q9score$PCAres$rotation[, 1:2]
# 
# # Convert the loadings to a data frame
# loadings_df <- as.data.frame(loadings)
# rownames_to_column(loadings_df, var = "variable")  # Convert row names to a column
# 
# # Create a base scatter plot of the PCA scores
# pca_plot <- ggplot(data = pca_scores_q9_df, aes(x = PC1, y = PC2)) +
#   geom_point() +
#   theme_minimal() +
#   labs(x = "Principal Component 1 (PC1)", y = "Principal Component 2 (PC2)",
#        title = "PCA Scatter Plot with Biplot Arrows for q9score")
# 
# # Add the biplot arrows to the plot
# pca_plot <- pca_plot + geom_segment(data = loadings_df, aes(x = 0, y = 0, xend = PC1, yend = PC2),
#                                     arrow = arrow(type = "closed", length = unit(0.2, "inches")),
#                                     color = "red", size = 0.5)
# 
# # Optionally, add text labels to the arrows to indicate variable names
# pca_plot <- pca_plot + geom_text(data = loadings_df, aes(x = PC1, y = PC2, label = variable),
#                                  color = "red", size = 3, vjust = 1.5, hjust = 1.5)
# 
# # Display the plot
# print(pca_plot)
library(dplyr)

# Filter the dataframe to only include time points 0 and 1
data_filtered <- data %>%
  filter(time %in% c(0, 1))

data_filtered <- data_filtered[!is.na(data_filtered$sme_name),]

# Find the fiscal_codes that have both time points 0 and 1
fiscal_codes_with_both_times <- data_filtered %>%
  group_by(fiscal_code) %>%
  filter(all(c(0, 1) %in% time)) %>%
  ungroup() %>%
  dplyr::select(fiscal_code) %>%
  distinct()

# Create a new dataframe that contains only the observations with both time points 0 and 1
data_panel <- data_filtered %>%
  semi_join(fiscal_codes_with_both_times, by = "fiscal_code")


# Calculate the difference in assess_date and filter out those with less than n months difference
monthslag <- 0

data_panel <- data_panel %>%
  group_by(fiscal_code, ent_name) %>%
  # Create a new dataframe that only contains fiscal codes with both time points
  filter(all(c(0, 1) %in% time)) %>%
  # Ensure that time 0 comes before time 1 for each fiscal code
  arrange(fiscal_code, time) %>%
  # Calculate the difference in 'assess_date' between time 1 and time 0
  mutate(
    diff_in_days = as.numeric(assess_date[time == 1] - assess_date[time == 0]),
    # Convert the difference in days to months and check if it's at least 12 months
    diff_in_months = diff_in_days / 30.44
  ) %>%
  # Filter out groups where the difference is less than 12 months
  # We check the first value because the difference will be repeated across rows in the same group
  filter(first(diff_in_months) >= monthslag) %>%
  # Remove the columns used for calculations
  select(-diff_in_days, -diff_in_months) %>%
  ungroup()


# Assuming 'data_panel' contains only observations for fiscal codes with both time points 0 and 1
# Calculate the difference in 'dmascore' between time 1 and time 0 for each 'fiscal_code'
data_change_in_dmascore <- data_panel %>%
  # Arrange the data to ensure that time 0 comes before time 1 for each fiscal code
  arrange(fiscal_code, time) %>%
  # Group by 'fiscal_code' to perform operations within each group
  group_by(fiscal_code) %>%
  # Use 'summarize' to calculate the change in 'dmascore' (assuming 'dmascore' is numeric)
  summarize(change_in_dmascore = dmascore[time == 1] - dmascore[time == 0],
            change_in_dbsscore = dbsscore[time == 1] - dbsscore[time == 0],
            change_in_drscore = drscore[time == 1] - drscore[time == 0],
            change_in_hcdscore = hcdscore[time == 1] - hcdscore[time == 0],
            change_in_dmscore = dmscore[time == 1] - dmscore[time == 0],
            change_in_aaiscore = aaiscore[time == 1] - aaiscore[time == 0],
            change_in_gdscore = gdscore[time == 1] - gdscore[time == 0]) %>%
  # Remove the grouping structure from the dataframe
  ungroup()

# View the results
# print(data_change_in_dmascore)

library(tidyr)
## 
## Caricamento pacchetto: 'tidyr'
## Il seguente oggetto è mascherato da 'package:igraph':
## 
##     crossing
## Il seguente oggetto è mascherato da 'package:reshape2':
## 
##     smiths
# Convert data from wide to long format
data_long <- data_change_in_dmascore %>%
  pivot_longer(
    cols = starts_with("change_in_"),   # Select columns that start with 'change_in_'
    names_to = "score_change_type",     # Name of the new column for score types
    values_to = "score_change_value"    # Name of the new column for score change values
  )

# Specify the desired order of the score change types
desired_order <- c("change_in_dmascore", "change_in_dbsscore", "change_in_drscore",
                   "change_in_hcdscore", "change_in_dmscore", "change_in_aaiscore",
                   "change_in_gdscore")

# Convert the 'score_change_type' to a factor with the specified levels
data_long$score_change_type <- factor(data_long$score_change_type, levels = desired_order)

# Calculate the mean for each score change type
means <- data_long %>%
  group_by(score_change_type) %>%
  summarize(mean_score_change = mean(score_change_value, na.rm = TRUE))

# Plot the data
ggplot(data_long, aes(x = score_change_type, y = score_change_value)) +
  geom_hline(yintercept = 0, linetype = "solid", color = "black", size = 1.5) + # Bold black line at 0 change
  geom_jitter(aes(color = score_change_type), width = 0.2, alpha = 0.5, size = 2) + # Clouds of dots
  geom_point(data = means, aes(x = score_change_type, y = mean_score_change), color = "red", size = 4) + # Mean points
  scale_color_manual(values = rep("blue", length(unique(data_long$score_change_type)))) + # Set the colors for the clouds of dots
  theme_minimal() +
  labs(x = "Score Change Type", y = "Change in Score", title = "Change in Scores Across Different Measures") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) # Rotate the x-axis text for readability
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Show the plot
ggsave(paste0(outputfolder,"/score_changes_plot.pdf"), width = 10, height = 6) # Save the plot as a PDF file
library(stargazer)

model_formula <- dma_score ~ sector + size + country

model <- lm(model_formula, data = data2)

stargazer(model, type = "text")
## 
## ===================================================================================
##                                                             Dependent variable:    
##                                                         ---------------------------
##                                                                  dma_score         
## -----------------------------------------------------------------------------------
## sectorAgricultural biotechnology and food biotechnology           -7.082*          
##                                                                   (3.656)          
##                                                                                    
## sectorAutomotive                                                  -7.836*          
##                                                                   (4.141)          
##                                                                                    
## sectorCommunity-Led Local Development                             -6.171           
##                                                                   (4.364)          
##                                                                                    
## sectorConstruction                                               Assembly          
##                                                                   (3.649)          
##                                                                                    
## sectorConsumer products                                           -3.887           
##                                                                   (3.722)          
##                                                                                    
## sectorCultural and creative economy                               -0.380           
##                                                                   (3.821)          
##                                                                                    
## sectorDefence                                                     -0.572           
##                                                                   (6.168)          
##                                                                                    
## sectorEducation                                                   -2.673           
##                                                                   (3.766)          
##                                                                                    
## sectorElectricity                                                 -0.685           
##                                                                   (4.567)          
##                                                                                    
## sectorEnergy                                                      -0.337           
##                                                                   (3.902)          
##                                                                                    
## sectorEnergy, fuels and petroleum engineering                      9.239           
##                                                                   (6.412)          
##                                                                                    
## sectorEnvironment                                                  0.730           
##                                                                   (3.929)          
##                                                                                    
## sectorFinancial                                                   -3.806           
##                                                                   (3.985)          
##                                                                                    
## sectorFishery                                                    -23.152**         
##                                                                  (11.363)          
##                                                                                    
## sectorFood and beverages                                          -5.020           
##                                                                   (3.743)          
##                                                                                    
## sectorHealth care                                                 -2.209           
##                                                                   (3.699)          
##                                                                                    
## sectorLeather                                                    -22.471**         
##                                                                  (11.305)          
##                                                                                    
## sectorLegal Aspects                                                0.401           
##                                                                   (6.717)          
##                                                                                    
## sectorLife sciences                                                0.753           
##                                                                   (3.943)          
##                                                                                    
## sectorManufacturing and processing                                -2.475           
##                                                                   (3.548)          
##                                                                                    
## sectorMaritime                                                     1.318           
##                                                                   (5.096)          
##                                                                                    
## sectorMetal working and industrial production                     -1.987           
##                                                                   (3.801)          
##                                                                                    
## sectorMining and extraction                                      -16.614**         
##                                                                   (8.353)          
##                                                                                    
## sectorNMP Non-Metallic Materials                              basic processes      
##                                                                   (8.397)          
##                                                                                    
## sectorPaper and wood                                              -7.164           
##                                                                   (4.780)          
##                                                                                    
## sectorPersonal services                                           -5.893           
##                                                                   (3.745)          
##                                                                                    
## sectorPolymers and plastics                                        3.019           
##                                                                   (5.031)          
##                                                                                    
## sectorPublic administration                                       -5.613           
##                                                                   (4.402)          
##                                                                                    
## sectorReal estate                                                 -0.877           
##                                                                   (4.296)          
##                                                                                    
## sectorRetail, wholesale or distribution                           -3.252           
##                                                                   (3.705)          
##                                                                                    
## sectorSecurity                                                     1.918           
##                                                                   (4.562)          
##                                                                                    
## sectorSmart City                                                   5.370           
##                                                                   (4.612)          
##                                                                                    
## sectorSpace                                                       11.240           
##                                                                   (8.345)          
##                                                                                    
## sectorTelecommunications                                           4.640           
##                                                                   (3.631)          
##                                                                                    
## sectorTextiles                                                   -9.048**          
##                                                                   (4.232)          
##                                                                                    
## sectorTransport                                                  Mobility          
##                                                                   (3.914)          
##                                                                                    
## sectorTransport sector                                            -2.824           
##                                                                   (4.813)          
##                                                                                    
## sectorTravel and tourism                                          -1.759           
##                                                                   (3.866)          
##                                                                                    
## sizeMedium-size (50-249)                                          -6.906           
##                                                                   (6.826)          
##                                                                                    
## sizeMicro-size (1-9)                                            -19.376***         
##                                                                   (6.828)          
##                                                                                    
## sizeMid-cap (500-2999 employees)                                   1.731           
##                                                                   (7.247)          
##                                                                                    
## sizeSmall-size (10-49)                                           -12.720*          
##                                                                   (6.828)          
##                                                                                    
## sizeSmall mid-cap (250-499 employees)                             -0.451           
##                                                                   (6.974)          
##                                                                                    
## countryBelgium                                                    -4.372           
##                                                                   (2.680)          
##                                                                                    
## countryBulgaria                                                 -16.362***         
##                                                                   (2.948)          
##                                                                                    
## countryCroatia                                                    -2.591           
##                                                                   (2.831)          
##                                                                                    
## countryCyprus                                                    -9.705***         
##                                                                   (3.676)          
##                                                                                    
## countryCzechia                                                  -13.193***         
##                                                                   (3.186)          
##                                                                                    
## countryDenmark                                                    -1.811           
##                                                                   (2.459)          
##                                                                                    
## countryEstonia                                                   -8.280***         
##                                                                   (2.212)          
##                                                                                    
## countryFinland                                                   10.812***         
##                                                                   (2.135)          
##                                                                                    
## countryFrance                                                   -17.711***         
##                                                                   (2.094)          
##                                                                                    
## countryGermany                                                    -1.627           
##                                                                   (2.278)          
##                                                                                    
## countryGreece                                                     -4.010*          
##                                                                   (2.063)          
##                                                                                    
## countryHungary                                                    -9.001*          
##                                                                   (4.887)          
##                                                                                    
## countryIceland                                                    -9.225           
##                                                                   (6.495)          
##                                                                                    
## countryIreland                                                    -0.149           
##                                                                   (2.514)          
##                                                                                    
## countryItaly                                                      -3.668*          
##                                                                   (2.209)          
##                                                                                    
## countryLatvia                                                    -6.694***         
##                                                                   (1.840)          
##                                                                                    
## countryLithuania                                                -18.474***         
##                                                                   (1.823)          
##                                                                                    
## countryLuxembourg                                                 -7.351           
##                                                                   (5.500)          
##                                                                                    
## countryMalta                                                       3.125           
##                                                                   (7.788)          
##                                                                                    
## countryNetherlands                                               -5.777**          
##                                                                   (2.254)          
##                                                                                    
## countryNorway                                                      5.444           
##                                                                   (4.909)          
##                                                                                    
## countryPoland                                                   -16.853***         
##                                                                   (4.169)          
##                                                                                    
## countryPortugal                                                    3.492           
##                                                                   (5.644)          
##                                                                                    
## countryRomania                                                    -0.165           
##                                                                   (4.069)          
##                                                                                    
## countrySlovakia                                                   -4.851           
##                                                                   (5.123)          
##                                                                                    
## countrySlovenia                                                  -4.806**          
##                                                                   (2.145)          
##                                                                                    
## countrySpain                                                      -1.468           
##                                                                   (1.841)          
##                                                                                    
## countrySweden                                                      0.357           
##                                                                   (4.460)          
##                                                                                    
## Constant                                                         63.552***         
##                                                                   (7.853)          
##                                                                                    
## -----------------------------------------------------------------------------------
## Observations                                                       3,203           
## R2                                                                 0.305           
## Adjusted R2                                                        0.289           
## Residual Std. Error                                         15.139 (df = 3131)     
## F Statistic                                              19.328*** (df = 71; 3131) 
## ===================================================================================
## Note:                                                   *p<0.1; **p<0.05; ***p<0.01
# Calculate average DMA score by sector
# Calculate average DMA score by sector, including only sectors with at least 30 observations
avg_score_by_sector <- data2 %>%
  group_by(sector) %>%
  filter(n() >= 30) %>%  # Include only sectors with at least 30 observations
  summarize(avg_dmascore = mean(dma_score, na.rm = TRUE)) %>%
  arrange(desc(avg_dmascore))

# Plot average DMA score by sector
sector_plot <- ggplot(avg_score_by_sector, aes(x = reorder(sector, -avg_dmascore), y = avg_dmascore)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = round(avg_dmascore, 1)), vjust = -0.5, size = 2) +  # Label placement and size
  labs(title = "Average DMA Score by Sector", x = "Sector", y = "Average DMA Score") +
  theme(axis.title.x = element_blank(),
        axis.text.x = element_text(angle = 70, hjust = 1),  # Rotate x-axis labels
        plot.margin = margin(t = 20, r = 20, b = 20, l = 20)) +  # Add margin to the plot area
  ylim(0, max(avg_score_by_sector$avg_dmascore) * 1.1)  # Set the y-axis limits

# Print the sector plot
print(sector_plot)

# Save the sector plot
ggsave(filename = file.path(outputfolder, "avg_dmascore_by_sector.png"), plot = sector_plot, device = "png", width = 12, height = 5, bg = "white")

# Calculate average DMA score by size, excluding "Large company (> 3000 employees)"
avg_score_by_size <- data2 %>%
  filter(size != "Large company (> 3000 employees)") %>%  # Exclude the specified category
  group_by(size) %>%
  summarize(avg_dmascore = mean(dma_score, na.rm = TRUE)) %>%
  arrange(desc(avg_dmascore))

# Plot average DMA score by size
size_plot <- ggplot(avg_score_by_size, aes(x = reorder(size, -avg_dmascore), y = avg_dmascore)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = round(avg_dmascore, 2)), vjust = -0.5, size = 4) +  # Label placement and size
  labs(title = "Average DMA Score by Size", x = "Size", y = "Average DMA Score") +
  theme(axis.title.x = element_blank(),
        axis.text.x = element_text(angle = 45, hjust = 1),  # Rotate x-axis labels
        plot.margin = margin(t = 20, r = 20, b = 20, l = 20)) +  # Add margin to the plot area
  ylim(0, max(avg_score_by_size$avg_dmascore) * 1.1)  # Set the y-axis limits

# Print the size plot
print(size_plot)

# Save the size plot
ggsave(filename = file.path(outputfolder, "avg_dmascore_by_size.png"), plot = size_plot, device = "png", width = 12, height = 5, bg = "white")

# Calculate average DMA score by size, excluding "Large company (> 3000 employees)"
avg_score_by_size <- data2 %>%
  filter(size != "Large company (> 3000 employees)") %>%  # Exclude the specified category
  group_by(size) %>%
  summarize(avg_dmascore = mean(dma_score, na.rm = TRUE)) %>%
  arrange(desc(avg_dmascore))

# Plot average DMA score by size
size_plot <- ggplot(avg_score_by_size, aes(x = reorder(size, -avg_dmascore), y = avg_dmascore)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = round(avg_dmascore, 2)), vjust = -0.5, size = 4) +  # Label placement and size
  labs(title = "Average DMA Score by Size", x = "Size", y = "Average DMA Score") +
  theme(axis.title.x = element_blank(),
        axis.text.x = element_text(angle = 45, hjust = 1),  # Rotate x-axis labels
        plot.margin = margin(t = 20, r = 20, b = 20, l = 20)) +  # Add margin to the plot area
  ylim(0, max(avg_score_by_size$avg_dmascore) * 1.1)  # Set the y-axis limits

# Print the size plot
print(size_plot)

# Save the size plot
ggsave(filename = file.path(outputfolder, "avg_dmascore_by_size.png"), plot = size_plot, device = "png", width = 10, height = 6, bg = "white")

# Function to calculate and plot average DMA score by size for a given category
plot_avg_dma_score_by_size <- function(data, category, output_name) {
  avg_score_by_size <- data %>%
    filter(size != "Large company (> 3000 employees)") %>%  # Exclude the specified category
    group_by(size) %>%
    summarize(avg_dmascore = mean(.data[[category]], na.rm = TRUE)) %>%
    arrange(desc(avg_dmascore))
  
  size_plot <- ggplot(avg_score_by_size, aes(x = reorder(size, -avg_dmascore), y = avg_dmascore)) +
    geom_bar(stat = "identity", fill = "steelblue") +
    geom_text(aes(label = round(avg_dmascore, 2)), vjust = -0.5, size = 4, fontface = "bold") +  # Label placement, size, and bold
    labs(title = paste("Average DMA Score by Size for", category), x = "Size", y = "Average Score") +
    theme(axis.title.x = element_blank(),
          axis.text.x = element_text(angle = 45, hjust = 1, face = "bold"),  # Rotate x-axis labels and make them bold
          plot.margin = margin(t = 20, r = 20, b = 20, l = 20)) +  # Add margin to the plot area
    ylim(0, 100)  # Set the y-axis limits
  
  # Print the size plot
  print(size_plot)
  
  # Save the size plot
  ggsave(filename = file.path(outputfolder, paste0(output_name, ".png")), plot = size_plot, device = "png", width = 6, height = 4, bg = "white")
}

# List of categories and corresponding output file names
categories <- c("dig_business_strat", "dig_readiness", "hum_centr_dig", "data_gov", "automation_ai", "green_dig")
output_names <- c("avg_dmascore_by_size_dig_business_strat", "avg_dmascore_by_size_dig_readiness", 
                  "avg_dmascore_by_size_hum_centr_dig", "avg_dmascore_by_size_data_gov", 
                  "avg_dmascore_by_size_automation_ai", "avg_dmascore_by_size_green_dig")

# Loop through each category and create the plots
for (i in seq_along(categories)) {
  plot_avg_dma_score_by_size(data2, categories[i], output_names[i])
}

# Calculate average score and quantiles for each dimension and overall score
summary_stats <- data.frame(
  dimension = c("dma_score", "dig_business_strat", "dig_readiness", "hum_centr_dig", "data_gov", "automation_ai", "green_dig"),
  avg = c(
    mean(data2$dma_score, na.rm = TRUE),
    mean(data2$dig_business_strat, na.rm = TRUE),
    mean(data2$dig_readiness, na.rm = TRUE),
    mean(data2$hum_centr_dig, na.rm = TRUE),
    mean(data2$data_gov, na.rm = TRUE),
    mean(data2$automation_ai, na.rm = TRUE),
    mean(data2$green_dig, na.rm = TRUE)
  ),
  q25 = c(
    quantile(data2$dma_score, 0.25, na.rm = TRUE),
    quantile(data2$dig_business_strat, 0.25, na.rm = TRUE),
    quantile(data2$dig_readiness, 0.25, na.rm = TRUE),
    quantile(data2$hum_centr_dig, 0.25, na.rm = TRUE),
    quantile(data2$data_gov, 0.25, na.rm = TRUE),
    quantile(data2$automation_ai, 0.25, na.rm = TRUE),
    quantile(data2$green_dig, 0.25, na.rm = TRUE)
  ),
  q75 = c(
    quantile(data2$dma_score, 0.75, na.rm = TRUE),
    quantile(data2$dig_business_strat, 0.75, na.rm = TRUE),
    quantile(data2$dig_readiness, 0.75, na.rm = TRUE),
    quantile(data2$hum_centr_dig, 0.75, na.rm = TRUE),
    quantile(data2$data_gov, 0.75, na.rm = TRUE),
    quantile(data2$automation_ai, 0.75, na.rm = TRUE),
    quantile(data2$green_dig, 0.75, na.rm = TRUE)
  )
)

# Ensure the dimensions are in the correct order
summary_stats$dimension <- factor(summary_stats$dimension, levels = c("dma_score", "dig_business_strat", "dig_readiness", "hum_centr_dig", "data_gov", "automation_ai", "green_dig"))

# Plot the data
dma_plot <- ggplot(summary_stats, aes(x = dimension, y = avg)) +
  geom_point(size = 4, color = "red") +
  geom_errorbar(aes(ymin = q25, ymax = q75), width = 0.2, color = "blue") +
  labs(title = "Average DMA Score and 25-75 Quantile Intervals by Dimension", x = "Dimension", y = "Score") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, face = "bold"),  # Rotate x-axis labels and make them bold
        plot.margin = margin(t = 20, r = 20, b = 20, l = 20))  # Add margin to the plot area

# Print the plot
print(dma_plot)

# Save the plot
ggsave(filename = file.path(outputfolder, "dma_score_quantiles.png"), plot = dma_plot, device = "png", width = 12, height = 5, bg = "white")